home *** CD-ROM | disk | FTP | other *** search
/ 100 Programas Essenciais Para Windows / +100 Programas Essenciais para Windows.iso / Suporte e Resolução de Problemas / User Profile Hive Cleanup / UPHClean-Setup.msi / _88F72A502D29482EA14F30DAAA16D0DE < prev    next >
Text File  |  2005-11-01  |  24KB  |  622 lines

  1. UPHClean v1.6d readme.txt
  2. Updated April 27, 2005 by Robin Caron
  3.  
  4. Send all feedback/comments/problems to uphclean@microsoft.com
  5.  
  6. WHAT IS UPHCLEAN
  7. ================
  8.  
  9. UPHClean is a service that once and for all gets rid of problems with user
  10. profile not unloading.
  11.  
  12. You are having profile unload problems if you experience slow logoff (with
  13. Saving Settings for most of the time while logging off), roaming profiles
  14. that do not reconcile, or the registry size limit is reached.
  15.  
  16. WHY DO PROFILES NOT UNLOAD?
  17. ===========================
  18.  
  19. Many system and service processes do work on behalf of users.  When the work
  20. is done the system or service process is responsible for releasing handles it
  21. has to the user profile hive.  If this is not done by the service as the user
  22. logs off the profile cannot be unloaded.
  23.  
  24. This problem in code can be caused by improper coding either in Microsoft
  25. software or 3rd party software (e.g. printer drivers, virus scanner service,
  26. etc).  With the information provided by the system there is no way to find
  27. out what software needs to be corrected to allow profiles to unload.
  28.  
  29. This problem can be caused for a variety of reasons.  While software developers
  30. are typically very careful about releasing handles, developing software that
  31. works on behalf of a logged on user is complicated.  It is difficult for
  32. software developer to have full control over how the registry is accessed.
  33. Service developers might want to see KB article 199190 for more information.
  34.  
  35. While it is possible to identify the service (see KB article 221833), it is
  36. sometimes difficult to track this down the specific problem code.  Even when
  37. you do identify the problem code there maybe times when the developer of this
  38. code is not able to make the necessary changes.  This is the reason for
  39. UPHClean -- it takes care of the problem regardless of the reason why.
  40.  
  41. WHAT DOES THE USER SEE?  WHAT HAPPENS TO THE PROFILE?
  42. =====================================================
  43.  
  44. Windows NT4:
  45. The system gives up immediately on failure to unload the profile
  46. and the (roaming) profile is not reconciled.
  47.  
  48. Windows 2000:
  49. The system attempts to unload the profile 60 times at 1 second intervals. 
  50. This retry logic rarely helps so in most cases after 60 seconds of the user
  51. waiting at the Saving Settings message box the system gives up and roaming
  52. profiles are not reconciled.  The number of retries can be changed to allow the
  53. user to log off faster (this can be done using the policy under Computer
  54. Configuration, Administrative Template, System, User Profiles, Maximum retries
  55. to unload and update user profile)
  56.  
  57. Windows XP and 2003:
  58. The profile is reconciled using a copy of the contents of the registry.  The
  59. user is not made to wait as in Windows 2000.  The problem left is that the
  60. computer cannot recover the memory the profile uses until it can be unloaded.  
  61.  
  62. Also in some cases (e.g. using anonymous logons) you may find that you cannot
  63. log on if the profile cannot be unloaded.
  64.  
  65. WHY SHOULD I USE UPHCLEAN?
  66. ==========================
  67.  
  68. The concept of UPHClean is to deal with these the same way the operating
  69. system deals with other resource issues: when a task is done resources
  70. (memory, handles, etc) are automatically reclaimed.  UPHClean accomplishes
  71. this simply by monitoring for users to log off and verifying that unused
  72. resources are reclaimed.  If they are not it reclaims the resource and logs
  73. its action.  This approach is superior as it works for any known reason
  74. that profiles do not unload and also will keep working to address new
  75. unknown issues.
  76.  
  77. Another advantage to UPHClean is that no computer restart is required to 
  78. install it or remove it (except on Windows NT 4).  You can install and
  79. remove UPHClean to find out whether it helps with a profile unload problem or
  80. not.  You can do this without having to worry about what hotfix, service pack,
  81. feature pack, etc has been installed.  Set it and forget is the goal of
  82. UPHClean.
  83.  
  84. By default UPHClean takes action to allow profiles to unload.  You can 
  85. choose to have UPHClean only report what processes it finds preventing profiles
  86. from unloading.  To do this, install UPHClean and use the registry editor to
  87. set:
  88.  
  89. HKLM\System\CurrentControlSet\Services\UPHClean\Parameters\REPORT_ONLY to 1.
  90.  
  91. You can also have UPHClean log the call stack that is responsible for the
  92. profile hive handle.  This is necessary to find out what software is
  93. responsible for the hive handle in processes used for many purposes (e.g.
  94. svchost.exe, dllhost.exe, winmgmt.exe).  To enable call stack logging use the
  95. registry editor to set:
  96.  
  97. HKLM\System\CurrentControlSet\Services\UPHClean\Parameters\CALLSTACK_LOG to 1.
  98.  
  99. Logging the call stack is computationally and memory intensive.  You should use
  100. this option to collect information and then turn it off.  To get more accurate
  101. call stack logging it may be necessary to get symbols installed on the
  102. computer.  You can read about getting symbols at:
  103.  
  104. http://www.microsoft.com/whdc/ddk/debugging/symbols.mspx
  105.  
  106. HOW CAN I TELL IF I'M HAVING A PROFILE UNLOAD PROBLEM?
  107. ======================================================
  108.  
  109. Events are recorded in the event log in most cases.  You can use Event Viewer
  110. to look for the following events:
  111.  
  112. Windows NT 4:
  113.  
  114. The application event log has error events with source Userenv, event id
  115. 1000.  The event text is:
  116.  
  117. The operating system was unable to load your profile.  Please contact
  118. your Network Administrator.
  119.  
  120. This is the only symptom you find in the event log of a Windows NT 4 computer
  121. indicating this problem is present.  The only way to be sure is to use UPHClean
  122. to find out if you have this problem or have some other problem.
  123.  
  124. Windows 2000:
  125.  
  126. The application event log has error events with source Userenv, event id
  127. 1000.  When you call up the event you get the one of following events:
  128.  
  129. Windows cannot unload your registry file.  If you have a roaming profile,
  130. your settings are not replicated. Contact your administrator.
  131.  
  132. DETAIL - Access is denied.
  133.  
  134. - or -
  135.  
  136. Windows cannot unload your registry class file.  If you have a roaming
  137. profile, your settings are not replicated. Contact your administrator.
  138.  
  139. DETAIL Access is denied.
  140.  
  141. - or - 
  142.  
  143. Windows cannot log you on because the profile cannot be loaded. Contact
  144. your network administrator.
  145.  
  146. This last error is relevant if you find one of the other ones earlier
  147. in the application log.
  148.  
  149. Windows XP and 2003:
  150.  
  151. You will see of the following error events in the application log:
  152.  
  153. Userenv/1517:
  154.  
  155. Windows saved user X registry while an application or service was still
  156. using the registry during log off. The memory used by the user's registry
  157. has not been freed. The registry will be unloaded when it is no longer in use.
  158.  
  159. This is often caused by services running as a user account, try configuring the
  160. services to run in either the LocalService or NetworkService account.
  161.  
  162. Userenv/1524:
  163.  
  164. Windows cannot unload your classes registry file - it is still in use by other
  165. applications or services. The file will be unloaded when it is no longer in use.
  166.  
  167. Userenv/1500:
  168.  
  169. Windows cannot log you on because your profile cannot be loaded. Check that you
  170. are connected to the network, or that your network is functioning correctly. If
  171. this problem persists, contact your network administrator. 
  172.  
  173. This last error (1500) is relevant if you find one of the other ones earlier in
  174. the application log.
  175.  
  176. INSTALLATION
  177. ============
  178.  
  179. To automatically install it (you need uphclean-setup.msi):
  180. - Double click the setup.msi
  181.  
  182. To manually install it (you need a copy of uphclean.exe):
  183.  
  184. - Create a directory under Program Files for the service
  185.      (e.g. c:\program files\uphclean)
  186. - Copy the program (uphclean.exe) to the directory
  187.      (e.g. c:\program files\uphclean\uphclean.exe)
  188. - Open a command prompt on the computer
  189. - Change directory where you copied the program
  190.      (e.g cd \program files\uphclean) 
  191. - Run the program with the -install switch to install the service and start it
  192.      (e.g. uphclean -install)
  193.  
  194. The service is set to automatically start when the computer boots so you will
  195. not need to start it manually.  Below I've listed the events that you will find
  196. in the application log when it takes positive steps to unload profile hives.
  197.  
  198. INSTALLATION PROBLEMS
  199. =====================
  200.  
  201. If you get an error using the MSI installation package and the package is on a 
  202. network share attempt the installation from a local drive.  Another alternative
  203. is to use the manual installation instructions.
  204.  
  205. If you have problems with the installation check to see if the following DLLs
  206. are in your c:\winnt\system32 directory:
  207.  
  208.     msvcp60.dll
  209.     msvcrt.dll
  210.  
  211. These files are commonly on computers because of other installed software.
  212. If you are missing these files you can visit:
  213.  
  214. http://support.microsoft.com/default.aspx?scid=259403
  215.  
  216. to download vcredist.exe which includes these files.
  217.  
  218. On Windows NT4 you will need to restart the computer.  On restart UPHClean will 
  219. start automatically.
  220.  
  221. UPGRADING
  222. =========
  223.  
  224. If you used the manual installation method to install UPHClean you must follow
  225. the manual removal instructions before attempting to use the MSI package to
  226. install.  You can find out if you used the MSI package by looking for an entry
  227. for User Profile Hive Cleanup Service in Add/Remove Programs under Control Panel.
  228.  
  229. If you used the MSI package to install then you can proceed with the new package
  230. without removal.
  231.  
  232. REMOVAL
  233. =======
  234.  
  235. If you used automatic installation:
  236. - Open Control Panel
  237. - Open Add/Remove Programs
  238. - Click on User Profile Hive Service and select Remove
  239.  
  240. If you manually installed:
  241. - Run the program with the -remove switch to stop the service and remove it
  242.   (e.g. uphclean -remove)
  243. - Remove the UPHClean directory under c:\program files
  244.  
  245. PROBLEMS USING UPHCLEAN
  246. =======================
  247.  
  248. Because UPHClean assists in unloading the users registry hive some services
  249. may behave incorrectly.  Administrators are encouraged to test and watch for
  250. unexpected behavior.  If unwanted behavior is identified contact the
  251. developers of software that UPHClean identified as preventing profile from
  252. unloading.
  253.  
  254. UPHClean assists the operating system to unload user profile hive by
  255. remapping the handles to the user profile hive to the default user hive.
  256. For example if a process has a handle to
  257. HKEY_USERS\S-1-5-21-X-Y-Z\Software\Microsoft after remapping it would have a
  258. handle to HKEY_USERS\.DEFAULT\Software\Microsoft.  This allows the profile
  259. hive to unload.  This may not work if the application expects data 
  260. that would only be available under the specific user profile hive it was
  261. accessing since the data will not be copied.  
  262.  
  263. If you find that removing UPHClean stops a particular problem from occurring
  264. then you may be interested in restricting UPHClean from processing certain
  265. handles.  UPHClean ignores handles that are held opened to profile hives for
  266. the users specified on the user exclusion list or by processes specified on the
  267. process exclusion list.  These lists are specified using the following
  268. registry values:
  269.  
  270. HKLM\System\CurrentControlSet\Services\UPHClean\Parameters\PROCESS_EXCLUSION_LIST
  271.  
  272. HKLM\System\CurrentControlSet\Services\UPHClean\Parameters\USER_EXCLUSION_LIST
  273.  
  274. Note that since these values are specified as REG_MULTI_SZ strings you should
  275. use regedt32 on Windows NT and Windows 2000 to edit them.
  276.  
  277. The process exclusion list is a list of process names that UPHClean should 
  278. ignore when determining which handles to user profile hives to act on.  Each
  279. process name is specified on its own line when input in registry editor.  The
  280. process name should be specified the same way as it shows in Task Manager.
  281. Usually this is the file name of the program (e.g. notepad.exe).
  282.  
  283. A few process show multiple times in Task Manager.  It is possible to specify
  284. that a certain DLL be loaded in the process to allow a selection of a specific
  285. process.  This is useful with the svchost process to identify a specific
  286. instance.  For example to specify the svchost process that the Remote Procedure
  287. Call (RPC) service is running in on Windows 2000, Windows XP and Windows Server
  288. 2003 you would specify svchost.exe/rpcss.dll in the process exclusion list.
  289.  
  290. The user exclusion list is a list of user security identifier (SID) or user
  291. that UPHClean should ignore when determining which handle to user profile hives
  292. to act on.  Each user SID or name is specified on its own line when input in
  293. registry editor.  If specifying a user name you must enter the user domain name
  294. followed by a backslash followed by the user name.  For example
  295. RCARONDOM\RCARON to specify the user RCARON from domain RCARONDOM.  SIDs should
  296. be specified in the usual string format (e.g. 
  297. S-1-5-21-2127521184-1604012920-1887927527-68486).  This is the same string you
  298. see under HKEY_USERS in registry editor.
  299.  
  300. Note that the user exclusion list always includes the following SIDs: S-1-5-18,
  301. S-1-5-19, S-1-5-20.  Unloading these profiles can cause problems so UPHClean
  302. will not attempt to process handles to these profiles.
  303.  
  304. Which processes UPHClean performs handle remapping can specified using the
  305. following registry value:
  306.  
  307. HKLM\System\CurrentControlSet\Services\UPHClean\Parameters\REMAP_HANDLE_PROCESS_LIST
  308.  
  309. The list by default contains '*' which specifies that handle remapping should
  310. be performed for all non-excluded processes.  This list can be changed to only
  311. include specified processes in the same manner as the process exclusion list.
  312. Processes specified on this list can be preceeded by a '-' character to specify
  313. that they should be excluded from handle remapping.  Any handle for a process
  314. that is not excluded but has handle remapping turned off will be closed.
  315.  
  316. LOGGED EVENTS
  317. =============
  318.  
  319. 1) Every time the User Profile Hive Cleanup service starts:
  320.  
  321. Event Type: Information
  322. Event Source: UPHClean
  323. Event Category: None
  324. Event ID: 1001
  325. Date:  11/14/2003
  326. Time:  10:13:45 PM
  327. User:  N/A
  328. Computer: RCARONDOM-DC1
  329. Description:
  330. User Profile Hive Cleanup Service version 1.X.Y.Z started successfully.
  331.  
  332. 2) Every time it stops:
  333.  
  334. Event Type: Information
  335. Event Source: UPHClean
  336. Event Category: None
  337. Event ID: 1010
  338. Date:  7/11/2003
  339. Time:  11:12:06 PM
  340. User:  N/A
  341. Computer: RCARONDOM-DC1
  342. Description:
  343. User Profile Hive Cleanup Service stopped successfully.
  344.  
  345. 3) Here the service is telling you that it closed handles that were preventing
  346. the profile from unloading:
  347.  
  348. Event Type:    Information
  349. Event Source:    UPHClean
  350. Event Category:    None
  351. Event ID:    1201
  352. Date:        11/14/2003
  353. Time:        10:26:29 PM
  354. User:        RCARONDOM\u1
  355. Computer:    RCARONDOM-DC1
  356. Description:
  357. The following handles in user profile hive RCARONDOM\u1
  358. (S-1-5-21-3230802392-3390281410-1560515013-1307) have been closed because they
  359. were preventing the profile from unloading successfully:
  360.  
  361. profleak.exe (1444)
  362.   HKCU (0x144)
  363.  
  364. If you have call stack logging the event will look like this:
  365.  
  366. Event Type:    Information
  367. Event Source:    UPHClean
  368. Event Category:    None
  369. Event ID:    1201
  370. Date:        10/21/2003
  371. Time:        5:17:38 PM
  372. User:        RCARONDOM-DC1\u1
  373. Computer:    RCARONDOM-DC1
  374. Description:
  375. The following handles in user profile hive RCARONDOM-DC1\u1
  376. (S-1-5-21-3230802392-3390281410-1560515013-1307) have been closed because they
  377. were preventing the profile from unloading successfully:
  378.  
  379. profleak.exe (2604)
  380.   HKCU (0x80)
  381.       0x77dfc200 ADVAPI32!TrackObject+0xe
  382.       0x00412112 profleak!<no symbol>
  383.       0x77db571b ADVAPI32!ScSvcctrlThreadA+0xe
  384.   HKCU\Software\Policies (0x88)
  385.       0x77dfc200 ADVAPI32!TrackObject+0xe
  386.       0x77da1949 ADVAPI32!RegOpenKeyExW+0x10b
  387.       0x0041350c profleak!<no symbol>
  388.       0x00412112 profleak!<no symbol>
  389.       0x77db571b ADVAPI32!ScSvcctrlThreadA+0xe
  390.  
  391. 4) Here's what it looks like if there's a problem closing handle held by 
  392. application.
  393.  
  394. Event Type: Information
  395. Event Source:   UPHClean
  396. Event Category: None
  397. Event ID: 1211
  398. Date:     7/11/2003
  399. Time:     9:46:29 PM
  400. User:     RCARONDOM\u1
  401. Computer: RCARONDOM-DC1
  402. Description:
  403. The following handles opened in user profile hive RCARONDOM\u1 
  404. (S-1-5-21-3230802392-3390281410-1560515013-1307) could not be closed:
  405.  
  406. profleak.exe (1148)
  407.   HKCU\SOFTWARE\Policies (0xb0) error 6
  408.  
  409. 5) Here the service is telling you that the user profile hive could not be 
  410. unloaded and that it will try again later.  I expect that this will occur 
  411. if the 1211 event occurred.  As I don't expect 1211 to occur I'd expect that 
  412. event id 1111 will not occur either.
  413.  
  414. Event Type: Warning
  415. Event Source: UPHClean
  416. Event Category: None
  417. Event ID: 1111
  418. Date:  7/11/2003
  419. Time:  9:46:50 PM
  420. User:  RCARONDOM\u1
  421. Computer: RCARONDOM-DC1
  422. Description:
  423. User profile hive RCARONDOM\u1 (S-1-5-21-3230802392-3390281410-1560515013-1307)
  424. failed to unload.  The unload will be retried. 
  425.  
  426. 6) If you are using the reporting only mode (see above on how to set) you will
  427. get event id 1501 whenever UPHClean detects a user logging off and the profile
  428. being held:
  429.  
  430. Event Type: Information
  431. Event Source: uphclean
  432. Event Category: None
  433. Event ID: 1501
  434. Date:  7/11/2003
  435. Time:  11:19:49 PM
  436. User:  RCARONDOM\u1
  437. Computer: RCARONDOM-DC1
  438. Description:
  439. The following handles opened in user profile hive RCARONDOM\u1
  440. (S-1-5-21-3230802392-3390281410-1560515013-1307) are preventing profiles from
  441. unloading:
  442.  
  443. profleak.exe (1364)
  444.   HKCU\SOFTWARE\Policies (0xb4)
  445.   HKCU (0xb8)
  446.  
  447. 7) If you are using the reporting only mode (see above on how to set) you will
  448. get event id 1511 whenever UPHClean detects a hive loaded for an extended
  449. period of time if the user is not logged on (whether there are handles
  450. to it or not).  This is important because it is possible that terminal
  451. server could run out of kernel mode resource (paged pool memory) when that
  452. happens.  This could lead to users being prevented from logging on.
  453.  
  454. Event Type:    Information
  455. Event Source:    UPHClean
  456. Event Category:    None
  457. Event ID:    1511
  458. Date:        10/21/2003
  459. Time:        5:13:18 PM
  460. User:        RCARONDOM\u1
  461. Computer:    RCARONDOM
  462. Description:
  463. User profile hive RCARONDOM\u1 (S-1-5-21-3230802392-3390281410-1560515013-1307)
  464. is loaded even though user is not logged on.
  465.  
  466. 8) If you use handle remapping instead of getting event id 1201 logged you will
  467. get event 1401:
  468.  
  469. Event Type:    Information
  470. Event Source:    UPHClean
  471. Event Category:    None
  472. Event ID:    1401
  473. Date:        10/26/2004
  474. Time:        9:56:52 PM
  475. User:        RCARON2-NC\u1
  476. Computer:    RCARON2-NC
  477. Description:
  478. The following handles in user profile hive RCARON2-NC\u1
  479. (S-1-5-21-796845957-1275210071-1801674531-1024) have been remapped because they
  480. were preventing the profile from unloading successfully: 
  481.  
  482. regopenkeyex.exe (368)
  483.   HKCU\Software\Classes\Software (0x4)
  484.  
  485. UPHCLEAN HISTORY
  486. ================
  487.  
  488. Apr 27, 2005 v1.6d (build 1.6.30.0)
  489.  
  490. If a user is logging off and the user profile hive is not unloading and 
  491. UPHClean is stopped it is possible that a STOP CE could occur.  To avoid
  492. this UPHClean delays has been modified to only complete its cleanup to 
  493. when it is being uninstalled.
  494.  
  495. Fixed error in UPHClean that could cause STOP 93 when protected handles were
  496. closed.
  497.  
  498. Added registry setting DISABLEREGFLUSHKEY.  This setting prevents user profile
  499. unload from causing a registry flush to disk.  In some cases poor performance
  500. affecting user application in other sessions can occur from doing this
  501. flushing.  The setting defaults to 0 which has no effect.  Setting it to 1
  502. prevents user profile unload from causing registry flushing.
  503.  
  504. Mar 15, 2005 v1.6b (build 1.6.0.26)
  505.  
  506. Fixed issue with handle remapping where if a handle to a profile hive is
  507. protected from close UPHClean would cause high CPU usage for large periods of
  508. time.
  509.  
  510. Handle remapping is now the default for all processes instead of handle closure.
  511.  
  512. Nov 12, 2004 v1.6 (build 1.6.0.24)
  513.  
  514. Added code to prevent UPHClean from closing handles held to user profile hives.
  515. This can be done using by user or process restriction.  Added code to allow
  516. remapping of handles.  This must be enabled by indicating which process
  517. remapping should be done for.
  518.  
  519. Corrected problem when on Windows 2000 if UPHClean had trouble closing handles
  520. to user profile hive logoff times could increase to about 15 minutes.
  521.  
  522. Corrected problem when stopping the UPHClean service while a user profile was
  523. being unloaded which could cause the machine to crash.
  524.  
  525. Corrected code to log UPHClean stop event (event id 1010) when system is
  526. shutdown.
  527.  
  528. Added code to set service description on Windows 2000 and later operating
  529. system.
  530.  
  531. Mar 4, 2004 v1.5e (build 1.5.4.21)
  532.  
  533. Added code to handle closure of handles for registry keys that were deleted.
  534. This covers scenarios where an application keeps a handle to a deleted
  535. registry key.  In that case Userenv would log profile unload problem events
  536. even if UPHClean was running.
  537.  
  538. Feb 25, 2004 v1.5d (build 1.5.4.20)
  539.  
  540. Added code to force closure of registry handles protected from close.  This
  541. avoids repeated events 1201 with the same process/handle combinations at 10
  542. second intervals.  Modified code to avoid license violation error on NT4.
  543.  
  544. Feb 12, 2004 v1.5c (build 1.5.0.18)
  545.  
  546. Cleaned up event 1201 message text.  Added code to delay initial scan for 
  547. profiles until operating system has been started for 1 minute.  Added logging
  548. code for event id 1501 to include user name.  First version available through
  549. Microsoft download.
  550.  
  551. Jan 14, 2004 v1.5b (build 1.5.0.11)
  552.  
  553. Improved detection of profile hive unload problem to allow UPHClean to release
  554. hive handles earlier than before allowing normal system function.  With this
  555. change the UPHClean 1201 event will be the only event logged.
  556.  
  557. Jan 5, 2004 v1.5 (build 1.5.0.8)
  558.  
  559. Added code to allow the call stack to be logged.  Modified code to handle
  560. scenario where UPHClean would not clean up profile handles if the profile is
  561. deleted at log off.
  562.  
  563. Sep 23, 2003 v1.2 (build 1.2.0.7)
  564.  
  565. Modified code to allow it to run on Windows NT 4.  Also added code to allow
  566. UPHClean to be used in monitoring mode.  In this mode UPHClean reports what
  567. process had handles to registry keys in user profile hives.  The name of the
  568. process, its id, the registry key name reported.
  569.  
  570. Sep 8, 2003 v1.1 (build 1.1.0.4)
  571.  
  572. Modified code flow to allow UPHClean to work on computers that do not have
  573. terminal services.  Modified code to immediately close handles to profile hives
  574. upon detection of user logoff.  The user can log off 20 seconds faster that way.
  575.  
  576. Jul 31, 2003 v1.0 (build 1.0.0.2)
  577.  
  578. First working version.
  579.  
  580. WORK FLOW
  581. =========
  582.  
  583.     hivestatus: hive name, prior refcount, refcount
  584.     hivetounload: hive name, next attempt (60 seconds)
  585.     pendinghiveunload: hive name, next attempt (10 seconds), last attempt (60 mins)
  586.     handletoclose: handle info
  587.  
  588.     wait until computer has been up for 1 minute
  589.  
  590.     on profile list change notify or service done or timeout (10 seconds if !pendinghiveunload.empty else 60 seconds)
  591.         if service done -- exit
  592.  
  593.         iterate through hive status:
  594.             prior refcount = refcount
  595.             update refcount
  596.             if refcount = 0 and loaded then
  597.                 if prior refcount != 0 then
  598.                     remove hive from hivetounload
  599.                     add hive to pendinghiveunload
  600.                         (next attempt = now, last attempt = now + 65 mins)
  601.             else
  602.                 remove hive from hivetounload
  603.                 remove hive from pendinghiveunload
  604.  
  605.         iterate through pendinghiveunload
  606.             if last attempt passed then 
  607.                 move hive to hivetounload (next attempt = now)
  608.  
  609.         if !pendinghiveunload.empty or !hivetounload.empty then
  610.             handletoclose = null
  611.             get handlelist
  612.             iterate through handlelist
  613.                 if (start(handle.name) in pendinghiveunload and nextattempt <= now) or
  614.                         (start(handle.name) in hivetounload and nextattempt <= now) then
  615.                     add entry to handletoclose
  616.  
  617.         process handletoclose (all handles on list are to be closed)
  618.  
  619.         process hivetounload (hives with nextattempt <= now should be unloaded)
  620.             no need to remove from list (will get done at next hive status update)
  621.  
  622.